]> git.r.bdr.sh - rbdr/captura/blame - Captura/Core Extensions/CVImageBuffer+cgImage.swift
Add sparkle
[rbdr/captura] / Captura / Core Extensions / CVImageBuffer+cgImage.swift
CommitLineData
c9b9e1d6
RBR
1import Foundation
2import ReplayKit
3
4extension CVImageBuffer {
5
082b61f3
RBR
6 private static let contextQueue = DispatchQueue(label: "com.example.contextQueue")
7 static let sharedContext: CIContext = {
8 return CIContext()
9 }()
7ee43fb8 10
c9b9e1d6 11 var cgImage: CGImage? {
082b61f3
RBR
12 var result: CGImage?
13 CVImageBuffer.contextQueue.sync {
14 let ciImage = CIImage(cvImageBuffer: self)
15 let width = CVPixelBufferGetWidth(self)
16 let height = CVPixelBufferGetHeight(self)
17 result = CVImageBuffer.sharedContext.createCGImage(ciImage, from: CGRect(x: 0, y: 0, width: width, height: height))
18 }
19 return result
c9b9e1d6
RBR
20 }
21}